package com.nuo.modules.visit.controller;



import com.nuo.modules.visit.entity.VisitEntity;
import com.nuo.modules.visit.service.VisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nuo.common.utils.R;


/**
 *
 *
 * @author nuo
 * @email 3033616351@qq.com
 * @date 2023-09-17 13:06:38
 */
@RestController
@RequestMapping("visit")
public class VisitController {
    @Autowired
    private VisitService visitService;

    /**
     * 获取访问首页的数量
     */
    @GetMapping("/getCnt")
    public R getCnt(){
        return R.ok().put("cnt", visitService.getById(1).getCnt());
    }

    /**
     * 用户访问首页
     */
    @PostMapping("/addCnt")
    public R addCnt(){
        VisitEntity visit = visitService.getById(1);
        visit.setCnt(visit.getCnt() + 1);
        visitService.updateById(visit);
        return R.ok();
    }


}
